starter.controller('checkTaskController', ['localStore','$rootScope','$window','$state','$ionicHistory','$timeout','$ionicScrollDelegate', '$scope', 'XCode','Page',
    function(localStore,$rootScope,$window,$state,$ionicHistory,$timeout,$ionicScrollDelegate, $scope, XCode, Page) {

        $scope.task = {};
        $scope.task.taskType = '1';
        $scope._pageSize = 20;
        $scope._pageIndex = 0;
        function getTaskList() {
            Page.ajaxPostQuiet(ApiEndpoint.mobileQueryUrl, {queryParam : $scope.task.queryParam,taskType : $scope.task.taskType,
                _pageSize : $scope._pageSize, _pageIndex : $scope._pageIndex}, function (resp) {
                $scope.dataList = resp.data.rows;
            });
        }

        getTaskList();


        changeSelect = function(obj,type) {
            $scope.task.taskType = type;

            $(obj).parent().find(".col").each(function(index,data){
                if($(data).attr("class") == ("col div_" + type)) {
                    $(data).find("a").css("color","#2D99F4");
                    $(data).find("a").next().css("display","block");
                } else {
                    $(data).find("a").css("color","#9F9F9F");
                    $(data).find("a").next().css("display","none");
                }
            });

            if(type == "2") {
                $("#headerBarInput").attr("placeholder","名称/街道/行向");
                getTaskList();
            } else if(type == "1") {
                $("#headerBarInput").attr("placeholder","车牌号/自编号/线路");
                getTaskList();
            } else if(type == "3") {
                $("#headerBarInput").attr("placeholder","名称/编号/类型");
                getTaskList();
            }
            $("#headerBarInput").val("");
            $scope.$apply($scope.task.taskType);
        }


        $("#headerBarInput").on("input",function(){
            $scope.task.queryParam = $("#headerBarInput").val();
            getTaskList();
        });

        $scope.clickItem = function(item) {
            item.taskType = $scope.task.taskType;
            localStore.setObject("selectItem",item);
            $state.go("check_detail");
        }

    }]);
